<template>

	<view>
		<view class="sticky-box">
			<uni-forms ref="baseForm" :modelValue="baseData" :rules="rules"> 
				<uni-forms-item label="关键字" required name="keyword">
					<uni-easyinput v-model="keyword" placeholder="请输入关键字" />
				</uni-forms-item>


				<uni-forms-item label="仓库" required name="WarehouseId">
					<uni-data-select v-model="WarehouseId" :localdata="Warehouse"></uni-data-select>
				</uni-forms-item>


			</uni-forms> 
			<button type="primary" @click="submit()">搜索</button>
		</view>
		<view>
		<uni-list v-for="(item,index) in list" :key="index">
			<view >
				<uni-list-item clickable :title="item.ProductCode" :show-badge="true" :note="item.ProductName"
					:rightText="item.note"></uni-list-item>
			</view>

		</uni-list>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				id: 0,
				list: [],
				keyword: '',
				WarehouseId: '',
				Warehouse: [],
			}
		},
		onLoad() {
			this.$api.Request({
				url: "/api/BasicData/GetWarehouse",
				method: 'GET',
				data: {},
			}).then((res) => {

				res.forEach(item => {

					this.Warehouse.push({
						value: item.Id,
						text: item.WarehouseName
					})

				});

			})




		},


		methods: {
			submit() {
			//this.list=[];	
			this.$api.Request({
				url: "/api/Report/Getkc?keyword=" + this.keyword + "&Warehouse=" + this.WarehouseId,
				method: 'GET',
				data: {},
			}).then((res) => {
			
				res.forEach(item => {
			
					this.list.push({
						id: item.Id,
						ProductCode: "编码:" + item.ProductCode+"名称:" + item.ProductName ,
						ProductName:  "规格:" + item.Cinvstd+"批次:" + item.Batch + "数量:" + item.Number,
						note: ''
					
					})
			
				});
			
			})

			},
		},

	}
</script>

<style>
	.sticky-box {

		/* #ifndef APP-PLUS-NVUE */

		display: flex;

		position: -webkit-sticky;

		/* #endif */

		position: sticky;

		top: var(--window-top);

		z-index: 40;

		flex-direction: row;

		margin: 0px;

		padding: 15px 0 15px 0;

		background-color: #F4F5F6;

		border-bottom-style: solid;

		border-bottom-color: #E2E2E2;

	}
</style>
